package cz.kfad.ofrss.activity;


import cz.kfad.ofrss.backend.BackendService;
import cz.kfad.ofrss.backend.IBackend;
import cz.kfad.ofrss.model.RssFeedShort;

import java.util.List;

public class CategoryActivity extends FeedListActivity {

    public static final String CATEGORY_ID_KEY = "CATEGORY_ID_KEY";

    private IBackend backend = BackendService.createBackend(this);

    @Override
    protected CharSequence getActivityTitle() {
        final int categoryId = getIntent().getIntExtra(CATEGORY_ID_KEY, -1);
        return backend.findCategoryById(categoryId).getName();
    }

    @Override
    protected List<RssFeedShort> getFeedList() {
        final int categoryId = getIntent().getIntExtra(CATEGORY_ID_KEY, -1);
        return backend.findFeedsForCategory(categoryId);
    }
}
